Skip to content

GH-10830: Add RestClient support for HTTP outbound endpoints#10835

Closed
mailaruns wants to merge 6 commits into
spring-projects:mainfrom
mailaruns:GH-10830
Closed

GH-10830: Add RestClient support for HTTP outbound endpoints#10835
mailaruns wants to merge 6 commits into
spring-projects:mainfrom
mailaruns:GH-10830

Conversation

@mailaruns

Copy link
Copy Markdown
Contributor
Fixes: gh-10830

* add `rest-client` XSD attribute for HTTP outbound gateway/channel adapter
* extend XML parsers to wire `RestClient` and reject mixed `rest-template` + `rest-client`
* add `HttpRequestExecutingMessageHandler` constructors and execution path for `RestClient`
* add DSL overloads in `Http` and `HttpMessageHandlerSpec` for preconfigured `RestClient`
* guard local client options (`request-factory`, `error-handler`, `message-converters`, `encoding-mode`) when external client is used
* add parser/DSL/handler tests, including invalid dual-client configuration cases
* update HTTP reference docs (`outbound`, `timeout`, `java-config`) for `RestClient` usage

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!
I left some review, but really nothing critical.
Thank you!

Comment thread src/reference/antora/modules/ROOT/pages/http/java-config.adoc Outdated
Comment thread src/reference/antora/modules/ROOT/pages/http/outbound.adoc Outdated

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, run ./gradlew :spring-integration-http:check before pushing changes to the PR.
Thanks

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rebase your branch to the latest main and run ./gradlew :spring-integration-http:check before pushing.
You have some Checkstyle violations:

Error: eckstyle] [ERROR] /home/runner/work/spring-integration/spring-integration/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java:207: Block tags have to appear in the order '[@param, @return, @throws, @since, @deprecated, @see]'. [AtclauseOrder]
Error: eckstyle] [ERROR] /home/runner/work/spring-integration/spring-integration/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java:222: Block tags have to appear in the order '[@param, @return, @throws, @since, @deprecated, @see]'. [AtclauseOrder]
Error: eckstyle] [ERROR] /home/runner/work/spring-integration/spring-integration/spring-integration-http/src/main/java/org/springframework/integration/http/outbound/HttpRequestExecutingMessageHandler.java:236: Block tags have to appear in the order '[@param, @return, @throws, @since, @deprecated, @see]'. [AtclauseOrder]

@mailaruns

Copy link
Copy Markdown
Contributor Author

Addressed in the latest commit.

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your change also deserves a [[x7.1-http-changes]] entry in the whats-new.adoc.

Thanks

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missed whats-new.adoc entry.
And ultimate goal is to not have deprecation warnings at all.

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rebase to the latest main.
Those failures in other modules should go away.
Also, whats-new.adoc might not merge clean, so keep a pulse on it when rebasing.

Thanks

Comment thread src/reference/antora/modules/ROOT/pages/whats-new.adoc Outdated

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange to have all my main changes in the PR.
Looks like you have done merge, but not rebase.
Please, try to fix your branch: https://stackoverflow.com/questions/804115/when-do-you-use-git-rebase-instead-of-git-merge

…points

    Fixes: spring-projectsgh-10830

    * add `rest-client` XSD attribute for HTTP outbound gateway/channel adapter
    * extend XML parsers to wire `RestClient` and reject mixed `rest-template` + `rest-client`
    * add `HttpRequestExecutingMessageHandler` constructors and execution path for `RestClient`
    * add DSL overloads in `Http` and `HttpMessageHandlerSpec` for preconfigured `RestClient`
    * guard local client options (`request-factory`, `error-handler`, `message-converters`, `encoding-mode`) when external client is used
    * add parser/DSL/handler tests, including invalid dual-client configuration cases
    * update HTTP reference docs (`outbound`, `timeout`, `java-config`) for `RestClient` usage

Signed-off-by: Arun Sethumadhavan <mailaruns@gmail.com>
…n and align with RestClient-first APIs

Fixes: spring-projectsgh-10830

* deprecate RestTemplate-based constructors and mutators in `HttpRequestExecutingMessageHandler` (`since = "7.1", forRemoval = true`)
* keep current runtime behavior stable in the handler (RestTemplate local path + RestClient external path) to avoid backward-compatibility regressions
* deprecate RestTemplate-based DSL factory methods in `Http` and align `RestClient` methods to `7.1` documentation
* rework `HttpMessageHandlerSpec` to use `RestClient.create(restTemplate)` for RestTemplate-based construction and simplify client state tracking
* deprecate RestTemplate-focused spec mutators (`requestFactory`, `errorHandler`, `messageConverters`) in favor of configuring `RestClient`
* update HTTP reference docs (`java-config`, `outbound`, `timeout`) with 7.1 RestClient guidance and RestTemplate deprecation notes
* adjust related tests/imports to match deprecation and client-selection changes

Signed-off-by: Arun Sethumadhavan <mailaruns@gmail.com>
Signed-off-by: Arun Sethumadhavan <mailaruns@gmail.com>
…on with RestClient.Builder

Fixes: spring-projectsgh-10830

* keep no-client `HttpRequestExecutingMessageHandler` constructors non-deprecated and use `@SuppressWarnings("removal")` where they delegate to deprecated RestTemplate constructors
* switch local (no external client) setup to `RestClient.Builder` and build the local `RestClient` in `doInit()`
* keep local mutator APIs (`setRequestFactory`, `setErrorHandler`, `setMessageConverters`) and apply them to the local `RestClient.Builder`
* rebuild the local `RestClient` after local mutator updates so post-init changes are visible at runtime
* retain guards that reject local-only options when an external RestTemplate/RestClient is provided
* handle `Void` response type in RestClient exchange path via `toBodilessEntity()` restoring prior behavior for bodiless replies.
* make `restClient` `volatile` because it is rebuilt and read across lifecycle/request threads
* remove deprecations from matching local mutators in `HttpMessageHandlerSpec`
* update outbound/parser/DSL tests to align with local RestClient-backed behavior
* adjust proxy and cookie test fixtures for RestClient path (including non-null request attributes in cookie request stub)

Signed-off-by: Arun Sethumadhavan <mailaruns@gmail.com>
…client lifecycle

Fixes spring-projectsgh-10830

* refactor nullable `RestClient` HTTP DSL factory methods to delegate via RestClient-first paths and remove duplicate fallback branches
* add shared `outboundGatewaySpec(...)` helpers in `Http` to centralize URI/String/Expression client selection
* add non-deprecated local constructors in `HttpMessageHandlerSpec` for URI/String/Expression paths
* keep deprecated RestTemplate DSL overloads and add `@SuppressWarnings("removal")` where they intentionally call deprecated constructors
* build local `RestClient` once in `HttpRequestExecutingMessageHandler#doInit()` and stop rebuilding on each local mutator call
* keep local mutators (`setRequestFactory`, `setErrorHandler`, `setMessageConverters`) applying to local `RestClient.Builder`
* align HTTP proxy test flow with lifecycle semantics by re-initializing after mutator-based setup
* revise HTTP proxy/cookie test fixtures and formatting updates for the current RestClient-backed local behavior
* add `[[x7.1-http-changes]]` section to `whats-new.adoc` documenting HTTP 7.1 updates

Signed-off-by: Arun Sethumadhavan <mailaruns@gmail.com>
Fixes: spring-projectsgh-10830

* route deprecated RestTemplate HTTP DSL/spec paths through RestClient.create(RestTemplate)
* remove deprecated internal-call suppressions in Http factory methods and simplify nullable RestClient delegation
* align HttpRequestExecutingMessageHandler default constructor flow with RestClient-first initialization
* switch local message converter setup to non-deprecated RestClient.Builder.configureMessageConverters API
* update HTTP parser/DSL tests and reduce deprecated-constructor warnings in outbound handler tests
* What's New entry for HTTP RestClient/RestTemplate migration notes

Signed-off-by: Arun Sethumadhavan <mailaruns@gmail.com>

@artembilan artembilan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything critical from here on GH.
Pulling locally for final review, clean up and merge.

Thanks

@artembilan

Copy link
Copy Markdown
Member

Merged as 1cfd8a5 after some minor cleanup.

Thank you for contribution; looking forward for more!

@artembilan artembilan closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants